﻿var prevSearch='';
function SearchData() {
    if($F('SearchText')!='')
    {
        if(prevSearch==$F('SearchText'))
        {
            new Effect.Appear($('divSearchResults'));
        }
        else
        {
            $('aSearch').innerHTML='Searching...';
            var data=$F('SearchText');
            var myAjax = new Ajax.Request(
                'handlers/search.ashx?status=search&criteria='+data,
                {method: 'post', parameters: data, onComplete: searchComplete}
            );
            prevSearch=$F('SearchText');
        }
    }
}
function searchComplete(originalRequest) {
    $('divSearchResults').innerHTML=originalRequest.responseText;
    new Effect.Appear($('divSearchResults'));
    $('aSearch').innerHTML='Completed';
    setTimeout('changeButton()',5000);
}
function changeButton()
{
    $('aSearch').innerHTML='Search';
}
function CloseSearch()
{
    new Effect.Fade($('divSearchResults'));
}